<template>
    <div>
        <h1>登录区域</h1>
        <table class="table table-bordered">
            <tr>
                <td>账户</td>
                <td> <input type="text" v-model="info.name"></td>
            </tr>
             <tr>
                <td>密码</td>
                <td> <input type="password" v-model="info.pwd"></td>
            </tr>
            <tr>
                <td></td>
                <td> <input type="button"class="btn btn-success" value="登录" @click="login"></td>
            </tr>
        </table>
    </div>
</template>

<script setup lang="ts">
import axios from 'axios';
import { ref,onMounted,reactive } from 'vue';
import { useRoute,useRouter } from 'vue-router';
const router =useRouter();
const info:any=reactive({
    name:"",
    pwd:""
})
const login=()=>{
    axios.get('https://localhost:7145/api/Emp/Login',{params:info}).then(res=>{
        if(res.data==-1)
    {
        alert('密码错误');
        return;
    }
    if(res.data==-2)
    {
        alert('账户错误');
        return;
    }
    else
    {
        if(info.name=="admin")
    {
        alert('登录成功,管理员')
        router.push('/card');
    }
    else
    {
        alert('登录成功')
        router.push('/caad');
    }
    }
    })
}
</script>

<style scoped>

</style>